package com.txunda.zhuohired.aty.manage.news;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.base.Base2Aty;
import com.txunda.zhuohired.dialog.DateDialog;
import com.txunda.zhuohired.dialog.SelectTimeDialog;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/14 9:14
 * 功能描述：面试申请处理
 * 联系方式：jiahuanchen@126.com
 */

public class ManageResumeSureAty extends Base2Aty {
    /**
     * 标题
     */
    @ViewInject(R.id.tv_layout_blue_center)
    private TextView tv_layout_blue_center;
    /**
     * 选择日期
     */
    @ViewInject(R.id.tv_manage_resume_sure_date)
    private TextView tv_manage_resume_sure_date;
    /**
     * 选择时间
     */
    @ViewInject(R.id.tv_manage_resume_sure_time)
    private TextView tv_manage_resume_sure_time;
    /**
     * 备注
     */
    @ViewInject(R.id.et_manage_resume_sure)
    private EditText et_manage_resume_sure;
    /**
     * 字数
     */
    @ViewInject(R.id.tv_manage_resume_sure_size)
    private TextView tv_manage_resume_sure_size;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showStatusBar(R.id.layout_blue_head);
        tv_layout_blue_center.setText("面试申请处理");
    }

    @Override
    @OnClick({R.id.tv_manage_resume_sure_date, R.id.tv_manage_resume_sure_time})
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.tv_manage_resume_sure_date://选择日期
                DateDialog dateDialog = new DateDialog(this, "选择面试日期", new DateDialog.SelectBirthdayListener() {
                    @Override
                    public void onSelectBirthday(String birthday) {
                        tv_manage_resume_sure_date.setText(birthday);
                    }
                });
                dateDialog.show();
                break;
            case R.id.tv_manage_resume_sure_time://选择时间
                SelectTimeDialog selectTimeDialog = new SelectTimeDialog(this, new SelectTimeDialog.SelectTimeListener() {


                    @Override
                    public void onSelectTime(String time) {
                        tv_manage_resume_sure_time.setText(time);
                    }
                });
                selectTimeDialog.show();
                break;
        }
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.aty_manage_resume_sure;
    }

    @Override
    protected void initialized() {

    }

    @Override
    protected void requestData() {
        et_manage_resume_sure.addTextChangedListener(new myTextWatcher());//显示汉字个数监听
    }

    /**
     * myTextWatcher实行TextWatcher
     * 接口并重写以下三种方法
     *
     * @author anynew
     */
    class myTextWatcher implements TextWatcher {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
            //在文本改变前执行
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {
            //当文本正在改变时执行
        }

        @Override
        public void afterTextChanged(Editable s) {
            //统计汉字的个数
            //设置文本内容
            tv_manage_resume_sure_size.setText(s.length() + "");
            if (s.length() >= 200) {
                tv_manage_resume_sure_size.setTextColor(Color.RED);
            } else {
                tv_manage_resume_sure_size.setTextColor(Color.BLACK);
            }

        }
    }

}
